package cn.attackme.myuploader.service.impl;

import cn.attackme.myuploader.dao.Gather_timeDao;
import cn.attackme.myuploader.dao.IndicatorDao;
import cn.attackme.myuploader.service.PlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PlanServiceImpl implements PlanService {
    @Autowired
    private IndicatorDao indicatorDao;
    @Autowired
    private Gather_timeDao gather_timeDao;


    @Override
    public List<Map<String, Object>> allplan() {
         List<Map<String, Object>> planlist = indicatorDao.allList();
        int[][] plan = new int[planlist.size()][20];

         List<Map<String, Object>> gather_plan = gather_timeDao.allList();
        for (int i = 0; i < gather_plan.size(); i++) {
            int date_index = (int) gather_plan.get(i).get("time_index_id");
            int indicator_index = (int) gather_plan.get(i).get("indicator_id");
            plan[indicator_index-1][date_index-1]= (int) gather_plan.get(i).get("colour");

        }
         for (int i = 0; i < planlist.size(); i++) {
             planlist.get(i).put("text", plan[i]);

         }

         return  planlist;
    }
}
